﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace PointTracker
{
    public partial class addRemoveProfessor : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //if (!IsPostBack)
            {
                if (Session["User"] == null)
                {
                    Response.Redirect("/");
                }
                else if (((User)Session["User"]).role != UserRole.Admin)
                {
                    Response.Redirect("/");
                }

            }
        }

        public void AddProfessor(Object sender, EventArgs e)
        {
            if (!TextBoxFname.Text.Trim().Equals("") &&
                !TextBoxLname.Text.Trim().Equals("") &&
                !TextBoxEmail.Text.Trim().Equals("") &&
                !TextBoxPassword.Text.Equals("") &&
                TextBoxPassword.Text.Equals(TextBoxVpassword.Text))
            {
                Boolean successful = PointTracker.User.adduser(TextBoxFname.Text, TextBoxLname.Text, TextBoxEmail.Text, TextBoxPassword.Text, UserRole.Professor,0);
                if (successful)
                {
                    Response.Redirect("~/Admin.aspx");
                }
                else
                {
                    Response.Redirect("~/Error/Default.aspx");
                }
            }
        }
    }
}